package com.yunhe.control;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.yunhe.bean.ShopUser;
import com.yunhe.service.checkUserService;



/**
 * Servlet implementation class ZhuCe
 */
@WebServlet("/qian/ZhuCe.do")
public class ZhuCe extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ZhuCe() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String uname=request.getParameter("name");
		String upass=request.getParameter("upass");
		String sex=request.getParameter("sex");		
		String uphone=request.getParameter("phone");
		String upro=request.getParameter("province");
		String[] split = upro.split(",");
		String proc1=split[1];
		String city = request.getParameter("city");
		String[] split2 = city.split(",");
		String city1=split2[1];
		String address=proc1+city1;
		System.out.println(address);
		ShopUser shopUser = new ShopUser();
		shopUser.setUname(uname);
		shopUser.setUpass(upass);
		shopUser.setUphone(uphone);
		shopUser.setUaddress(address);
		shopUser.setUsex(sex);
		int ins = new checkUserService().InsertUser(shopUser);
		if(ins>0){
			response.sendRedirect("./login.jsp");
		}else{
			response.sendRedirect("./regist.jsp");
		}
	}

}
